import pandas as pd

# 日期
# line = '2025-08-03 00:00:00'
# # print(line[5:7])
# print(pd.to_datetime(line).weekday())
# print('----'*20)


# 示例数据
# result = pd.DataFrame({'hour': [10, 12, 10, 14]})
# # print(result)
# # 基本用法
# dummies = pd.get_dummies(result['hour'], prefix='hour').astype(int)
# print(dummies)



# 原始数据
data = pd.DataFrame({'power_load': [100, 150, 200, 250, 300]})

'''
时间序列分析的核心工具: shift
shift(i) : 将数据沿时间轴向后平移 i 个时间步
'''
# 创建滞后特征（window_size=3）
window_size = 3
shift_list = [data['power_load'].shift(i) for i in range(1, window_size + 1)]
# print(shift_list)
# enumerate(..., start=1): 为滞后特征生成从1开始的序号
for i, shifted in enumerate(shift_list, start=1):
    data[f'lag_{i}'] = shifted
